<h1 class="page-header">
    <small>编辑商品分类</small>
</h1>
<hr/>
<div class="panel panel-inverse" data-sortable-id="form-stuff-1">
    <div class="panel-heading">
        <h4 class="panel-title">分类信息</h4>
    </div>
    <div class="panel-body">
        <form class="form-horizontal" id="cateForm" name="cateForm" action="" method="post">
            <input id="id" type="hidden" name="id" value="${info.id}">
            <div class="form-group">
                <label class="col-md-3 control-label"><span class="requiredstar">* </span>名称：</label>
                <div class="col-md-3">
                    <input type="text" id="name" class="form-control" name="name" value="${info.name}" placeholder="名称，长度1-100" rangelength="1, 100" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">图片：</label>
                <div class="col-md-3">
                    <img name="image1" class="m-r-20 m-b-10" id="image1" src="${imagePath}${info.logo}" style="border:1px solid #ccc;border-radius:1px;width: 120px;height: 80px;">
                    <input type="file" name="picture1" id="picture1" style="display: inline-block" onchange="ajaxFileUpload(1,'${rc.contextPath}/backend');">
                    <div style="color:#cccccc;margin-bottom: 10px;">（格式：jpeg/jpg/png，大小：540x300）</div>
                    <input type="hidden" placeholder="图片路径" class="form-control" name="image" id="filePath1" value="${info.logo}" onchange="changeImagePath('<@mh.static/>', '1')">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label"><span class="requiredstar">* </span>排序：</label>
                <div class="col-md-3">
                     <input type="text" id="sort" class="form-control" name="sort" value="${info.sort}" placeholder="排序，正整数" rangelength="1, 100">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">描述：</label>
                <div class="col-md-5">
                    <textarea rows="5" class="form-control" id="description" name="description" maxlength="1000" placeholder="描述信息">${info.description}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">状态：</label>
                <div class="col-md-2">
                    <select class="form-control" name="status" id="status">
                        <option value="A" <#if info.status == "A">selected</#if>>启用</option>
                        <option value="D" <#if info.status == "D">selected</#if>>禁用</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label"></label>
                <div class="col-md-9">
                    <button type="button" id="submitButton" class="btn btn-sm btn-success">提交</button>
                    <button type="button" class="btn btn-sm btn-danger"
                            onclick="getData('${rc.contextPath}/backend/goods/cate/list','displayArea')">返回
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="application/javascript">
    $(function () {
        $('#submitButton').click(function () {
            if ($("#name").val() != null || $("#name").val() != "") {
                $('#cateForm').submit();
            }
        });

        $('#cateForm').validate({
            rules: {},
            messages: {},
            errorPlacement: function (error, element) {
                error.appendTo(element.parent());
            },
            submitHandler: function () {
                postDataByFormParams('${rc.contextPath}/backend/goods/cate/update', 'displayArea', 'cateForm');
            }
        })
    })
</script>

